package com.ieds.web.service;

import com.ieds.core.dto.BootTablePage;
import com.ieds.core.mapper.DatabaseRecordDao;
import com.ieds.core.model.KDatabaseMonitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: wanglei
 * @Date: 2020.05.29
 * @Description: com.ieds.web.service
 */
@Service
public class DatabaseRecordService {

    @Autowired
    private DatabaseRecordDao databaseRecordDao;

    public BootTablePage getList(Integer start, Integer size, Integer databaseId,String startTime, String finishTime) {
        KDatabaseMonitor template = new KDatabaseMonitor();
        if (databaseId != null){
            template.setDatabaseId(databaseId);
        }
        List<KDatabaseMonitor> kDatabaseMonitorList = databaseRecordDao.pageQueryRecord(template, start, size, startTime, finishTime);
        Long totalCount = databaseRecordDao.allCountRecord(template,startTime, finishTime);

        BootTablePage bootTablePage = new BootTablePage();
        bootTablePage.setRows(kDatabaseMonitorList);
        bootTablePage.setTotal(totalCount);
        return bootTablePage;
    }

}
